import * as echarts from "echarts";

export class StatBase {
    verticalBarOpt: any = {
        color: ["#3398DB"],
        title: {
            text: "",
            x: "center",
            textStyle: {
                color: "#777",
                fontSize: 15
            }
        },
        grid: {
            top: "12%",
            left: "4%",
            right: "4%",
            bottom: "5%",
            containLabel: true
        },
        tooltip: {
            trigger: "axis",
            axisPointer: {
                type: "shadow"
            }
        },
        xAxis: {
            type: "category",
            data: [],
            axisLabel: {
                textStyle: {
                    color: "#777"
                }
            }
        },
        yAxis: {
            type: "value",
            axisLine: {
                show: false
            }
        },
        series: [
            {
                type: "bar",
                data: [],
                barCategoryGap: "60%",
                itemStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                            {offset: 0, color: "#83bff6"},
                            {offset: 1, color: "#74c5ff"}
                        ])
                    }
                }
            }
        ]
    };
    scatterOpt: any = {
        title: {
            text: "",
            x: "center",
            textStyle: {
                color: "#777",
                fontSize: 15
            }
        },
        grid: {
            top: "20%",
            left: "4%",
            right: "6%",
            bottom: "8%",
            containLabel: true
        },
        xAxis: {
            nameGap: 24,
            nameLocation: "middle",
            nameTextStyle: {
                color: "#777",
                fontSize: 13
            },
            splitLine: {
                lineStyle: {
                    type: "dashed"
                }
            }
        },
        yAxis: {
            min: 0,
            name: "数量(个)",
            nameTextStyle: {
                color: "#777",
                fontSize: 13
            },
            splitLine: {
                lineStyle: {
                    type: "dashed"
                }
            }
        },
        series: [
            {
                symbolSize: 14,
                data: [],
                type: "scatter",
                emphasis: {
                    label: {
                        show: true,
                        formatter: param => {
                            return `${param.data[2]}:${param.data[1]}`;
                        },
                        position: "top",
                        offset: [-20, 0]
                    }
                },
                itemStyle: {
                    shadowBlur: 10,
                    shadowColor: "rgba(25, 100, 150, 0.5)",
                    shadowOffsetY: 5,
                    color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
                        {
                            offset: 0,
                            color: "rgb(129, 227, 238)"
                        },
                        {
                            offset: 1,
                            color: "rgb(25, 183, 207)"
                        }
                    ])
                }
            }
        ]
    };
    pieOpt: any = {
        color: [
            "#8de3ff",
            "#1aa7ee",
            "#72eef0",
            "#797ff3",
            "#1e2f96",
            "#37a2da",
            "#9fe6b8"
        ],
        title: {
            text: "",
            x: "center",
            top: 4,
            textStyle: {
                color: "#777",
                fontSize: 14
            }
        },
        grid: {
            top: "16%",
            left: "10%",
            right: "10%",
            bottom: 0,
            containLabel: true
        },
        tooltip: {
            trigger: "item",
            formatter: "{b} : {c} ({d}%)"
        },
        series: [
            {
                type: "pie",
                radius: "50%",
                center: ["50%", "50%"],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: "rgba(0, 0, 0, 0.5)"
                    }
                },
                // labelLine: {
                //     normal: {
                //         length: 5,
                //         length2: 5
                //     }
                // },
                label: {
                    // formatter: "{b|{b}：}{c}" +
                    //     "\n" +
                    //     "{per|{d}%}",
                    formatter: "{b|{b}：}{c} {per|{d}%}",
                    position: 'outer',
                    alignTo: 'edge',
                    margin: '3%',
                    rich: {
                        b: {
                            fontSize: 13,
                            lineHeight: 24
                        },
                        per: {
                            color: "#eee",
                            backgroundColor: "#334455",
                            padding: [2, 4],
                            borderRadius: 2
                        }
                    }
                },
                data: []
            }
        ]
    };

    constructor() {
    }
}
